<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ui>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="/hrms/css/styles.css" />
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="/hrms/css/flexigrid.css" />
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="/hrms/css/flexigrid.pack.css" />
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="/hrms/css/ztree.css" />

		<script type="text/javascript"
			src="/hrms/js/jquery-1.7.2.min.js"></script>

		<script type="text/javascript"
			src="/hrms/js/jquery.container.js"></script>

		<script type="text/javascript"
			src="/hrms/js/common.js"></script>

		<script type="text/javascript"
			src="/hrms/js/flexigrid.pack.js"></script>

		<script type="text/javascript">
	$(document).ready( function() {
		demand("servicemgr");
		$("#bn_query").click(function(){
			var servicecode=$("#servicecode").val();
			var servicename=$("#servicename").val();
			var extParams={extParam:[{name:"servicecode",value:servicecode},{name:"servicename",value:servicename}]};
			$("#querylist").flexOptions(extParams).flexReload();
		});
		$("#bn_add").click(function(){
			$("#fm_add").ajaxSubmit({success:function(){
				$("#dl_add").dialog("close");
				alert("服务添加成功");
				$("#querylist").flexReload();
			},error:function(){
				alert("服务添加失败！");
			}});
		});
		$("#bn_update").click(function(){
			$("#fm_update").ajaxSubmit({success:function(){
				$("#dl_update").dialog("close");
				alert("服务编辑成功!");
				$("#querylist").flexReload();
			},error:function(){
				alert("服务编辑失败！");
			}});
			
		});
		$("#dl_add").dialog("close");
		$("#dl_update").dialog("close");
	});
</script>

	</head>

	<body onload="loadDemand('servicemgr')">
		<div align="center">
			<br />
			<br />
			<br />
			<table width="80%" border="0" class="table_frame" align="center">

				<thead class="table_title">
					<tr><td align="center">
						服务信息管理
					</td></tr>
				</thead>
				<tr>
					<td>
						<table width="100%" border="0" class="table_block">
							<tr>
								<td align="right">
									服务编号：
								</td>
								<td align="left">
									<input id="servicecode" name="servicecode" type="text" size="20" />
									&nbsp;
								</td>
								<td align="right">
									服务名称：
								</td>
								<td align="left">
									<input id="servicename" name="servicename" type="text" size="20" />
								</td>
							</tr>
							<tr>
								<td colspan="4" align="center">
									<input id="bn_query" name="query" type="button" value="查询" class="button_image" />
									<input name="" type="reset" class="button_image" />
								</td>

							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="20"></td>
				</tr>
				<tr>
					<td>
						<div>
							<table id="querylist"></table>
							<script type="text/javascript">
	$("#querylist").flexigrid( {
		url :'/hrms/webservice/resources/service/queryByPage',
		dataType :'json',
		colModel : [ {
			display :'服务编号',
			name :'servicecode',
			width :160,
			sortable :true,
			align :'center'
		}, {
			display :'服务名称',
			name :'servicename',
			width :80,
			sortable :true,
			align :'right'
		}, {
			display :'服务中文名称',
			name :'displayname',
			width :180,
			sortable :true,
			align :'left'
		},{
			display:'服务隶属功能编号',
			name:'functioncode',
			width:80,
			sortable:true,
			align:'left',
			hide:true
		},{
			display :'服务隶属功能',
			name :'functionname',
			width :180,
			sortable :true,
			align :'left'
		},{
			display :'资源名称',
			name :'resourcesname',
			width :120,
			sortable :true,
			align :'left'
		}, {
			display :'资源中文名称',
			name :'displayresourcename',
			width :130,
			sortable :true,
			align :'left',
			hide :true
		},{
			display :'服务状态',
			name :'state',
			width :80,
			sortable :true,
			align :'right',
			hide:true
		},{
			display:'服务状态',
			name:'stateStr',
			width:80,
			sortable:true
		} ],
		buttons : [ {
			name :'新增服务',
			bclass :'add',
			onpress :add
		}, {
			name :'服务编辑',
			bclass :'edit',
			onpress :update
		}, {
			name :'删除服务',
			bclass :'delete',
			onpress :remove
		}, {
			separator :true
		} ],
		searchitems : [ {
			display :'服务编号',
			name :'iso'
		}, {
			display :'服务名称',
			name :'name',
			isdefault :true
		} ],
		sortname :"服务编号",
		sortorder :"servicecode",
		usepager :true,
		title :'服务信息列表',
		funcp :true,
		rp :15,
		showTableToggleBtn :true,
		width :1000,
		height :200
	});
	function add(com, grid) {
		$.ajax({url:"/hrms/webservice/resources/keyGen/genKey?tablecode=RBAC_SERVICE&custom=",
			dataType:"json",
			sucess:function(data){
			},error:function(XMLHttpRequest, textStatus, errorThrown){
			    $("#a_servicecode").attr("value",XMLHttpRequest.responseText);
			    $("#dl_add").dialog("open");
			}});
	}
	function update(com, grid) {
		//获得选中的记录
		var selected_length=$(".trSelected",grid).length;
		if(selected_length<1){
			alert("请选择一条需要编辑的服务后，再点击服务编辑按钮！");
			return false;
		}
		if(selected_length>1){
			alert("编辑服务只能选择一条记录进行处理，请重新选择！");
			return false;
		}
		var servicecode=$(".trSelected td:nth-child(1) div",grid).text();
		$.ajax({
			url:"/hrms/webservice/resources/service/getDetail?servicecode="+servicecode,
			success:function(_data){
				$("body").DataLink({
					data : _data,
					formId :"fm_update"
				});
			},
			error:function(){
				alert("获取服务详细信息时出现异常！");
			}
		});
		$("#dl_update").dialog("open");
	}
	function remove(com, grid) {
		//获得选中的记录
		var selected_length=$(".trSelected",grid).length;
		if(selected_length<1){
			alert("请选择一条需要编辑的服务后，再点击服务编辑按钮！");
			return false;
		}
		var iscon=confirm('确认要删除选中的服务吗？');
		if(iscon){
			$(".trSelected td:nth-child(6) div",grid).each(function(index){
				var state=$(this).text();
				if(state==="1"){
					alert("服务的状态为正常的不能被删除，请将权限解除后再行删除！");
					return ;
				}
			});
			var codes="";
			$(".trSelected td:nth-child(1) div",grid).each(function(index){
				if(index)
					codes+=",";
				codes+=$(this).text();
			});
			$.ajax({
				url:"/hrms/webservice/resources/service/delete?servicecodes="+codes,
				success:function(data){
					alert("删除服务成功！");
					$("#querylist").flexReload();
				},
				error:function(){
					alert("删除服务失败！");
				}
			});
			}
	}
</script>
						</div>
					</td>
				</tr>
			</table>
			<div align="center">
				<br />
				<br />
				<table width="90%" border="0" class="table_frame" align="center">
					<tr>
						<td align="center">
							<input id="demand" name="" type="button" value="需求收集"
								class="button_image" />
						</td>
					</tr>
					<tr>
						<td align="center">
							<div id="demand_input" style="display: none">
								<textarea rows="15" cols="120" id="demand_text"></textarea>
								<br />
								<input id="demand_save" type="button" class="button_image"
									value="保存需求" />
							</div>
						</td>
					</tr>
				</table>
				<table id="demand_des" width="90%" border="0" class="table_frame"
					align="center">
					<thead align="center" class="table_title">
						<tr><td>
							需求描述
						</td>
						</tr>
											</thead>
				</table>
			</div>
		</div>
		<ui:dialog id="dl_add" title="服务新增" height="300" width="700"
			modal="true">
			<form id="fm_add"
				action="/hrms/webservice/resources/service/add"
				method="post">
				<table class="table_frame" width="100%">
					<tr>
						<td align="right">
							服务编号:
						</td>
						<td align="left">
							<input type="text" id="a_servicecode" name="servicecode"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
						<td align="right">
							服务名称:
						</td>
						<td align="left">
							<input type="text" name="servicename"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
					</tr>
					<tr>
						<td align="right">
							资源中文名称:
						</td>
						<td align="left">
							<input type="text" name="displayresourcename"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
						<td align="right">
							资源名称:
						</td>
						<td align="left">
							<input type="text" name="resourcename" size=20 />
							<font color="red">*</font>
						</td>
					</tr>
					<tr>
						<td align="right">
							服务中文名称:
						</td>
						<td align="left">
							<input name="displayname" type="text" size=20 />
						</td>
						<td align="right">
							服务状态:
						</td>
						<td align="left">
							<select name="state" style="width:160px;"  onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
								<option value="0">
									新增
								</option>
								<option value="1">
									正常
								</option>
								<option value="2">
									注销
								</option>
							</select>
						</td>
					</tr>
					<tr>
					<td align="right">
							服务备注:
						</td>
						<td align="left" colspan="3">
							<textarea cols="50" rows="4" id="" name=""></textarea>
						</td>
					</tr>
					<tr>
						<td align="right" colspan="2">
							<input type="button" value="保存" class="button_image" id="bn_add" />
						</td>
						<td align="left" colspan="2">
							<input type="reset" value="重置" class="button_image" />
						</td>
					</tr>
				</table>
			</form>
		</ui:dialog>
		<ui:dialog id="dl_update" title="服务信息编辑" height="300" width="700"
			modal=true>
			<form id="fm_update"
				action="/hrms/webservice/resources/service/update"
				method="post">
				<input type="hidden" name="annalidStr"/>
				<input type="hidden" name="valid"/>
				<table class="table_frame" width="100%">
					<tr>
						<td align="right">
							服务编号:
						</td>
						<td align="left">
							<input type="text" name="servicecode"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
						<td align="right">
							服务名称:
						</td>
						<td align="left">
							<input type="text"  name="servicename"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
					</tr>
					<tr>
						<td align="right">
							资源中文名称:
						</td>
						<td align="left">
							<input type="text" name="displayresourcename"
								class="validate[required] text-input" maxlength="128"></input>
							<font color="red">*</font>
						</td>
						<td align="right">
							资源名称:
						</td>
						<td align="left">
							<input type="text" name="resourcename" size=20 />
						</td>
					</tr>
					<tr>
						<td align="right">
							服务中文名称:
						</td>
						<td align="left">
							<input  type="text" name="displayname" size=20 />
							</td>
						<td align="right">
							服务状态:
						</td>
						<td align="left">
							<select name="state" style="width:160px;"  onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
							<option value="0">
									新增
								</option>
								<option value="1">
									正常
								</option>
								<option value="2">
									注销
								</option>
							</select>
						</td>
					</tr>
					<tr>
					<td align="right">
							服务备注:
						</td>
						<td align="left" colspan="3">
							<textarea cols="50" rows="4" id="" name=""></textarea>
						</td>
					</tr>
					<tr>
						<td align="right" colspan="2">
							<input type="button" value="保存" class="button_image" id="bn_update" />
						</td>
						<td align="left" colspan="2">
							<input type="reset" value="重置" class="button_image" />
						</td>
					</tr>
				</table>
			</form>
		</ui:dialog>
	</body>
</html>
